//
//  HEPayResultResViewController.m
//  HealthFamily
//
//  Created by 吴欧 on 2020/10/29.
//  Copyright © 2020 honglutec. All rights reserved.
//

#import "HEPayResultResViewController.h"
#import "HEOrderViewController.h"

@interface HEPayResultResViewController ()

@property (nonatomic, strong) UILabel *noticeLb;

@end

@implementation HEPayResultResViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.title = @"订单支付";
    self.zx_navStatusBarStyle = ZXNavStatusBarStyleDefault;
    [self initUI];
}

- (void)initUI {

    UIImageView *payView = [UIImageView new];
    payView.image = IMAGE_NAMED(@"pay_success");
    [self.view addSubview:payView];
    
    _noticeLb = [UILabel new];
    _noticeLb.textAlignment = NSTextAlignmentCenter;
    _noticeLb.text = @"支付成功";
    _noticeLb.font = DYBlodFont(18);
    [self.view addSubview:_noticeLb];

    // 底部按钮
    UIView *btnWarp = [UIView new];
    [self.view addSubview:btnWarp];
    
    QMUIGhostButton *orderBtn = [[QMUIGhostButton alloc] initWithGhostColor:CNavBgColor];
    orderBtn.titleLabel.font = UIFontMake(18);
    [orderBtn setTitle:@"我的订单" forState:UIControlStateNormal];
    [btnWarp addSubview:orderBtn];

    QMUIFillButton *shopBtn = [[QMUIFillButton alloc] initWithFillColor:CNavBgColor titleTextColor:CNavBgFontColor];
    shopBtn.titleLabel.font = UIFontMake(18);
    [shopBtn setTitle:@"继续购物" forState:UIControlStateNormal];
    [btnWarp addSubview:shopBtn];
    
    [orderBtn addTarget:self action:@selector(toOrderListClick) forControlEvents:UIControlEventTouchUpInside];
    [shopBtn addTarget:self action:@selector(toShopClick) forControlEvents:UIControlEventTouchUpInside];
    
    [payView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.equalTo(self.view).mas_offset(ZXNavBarHeight + 78);
        make.width.height.mas_offset(67);
    }];
    
    [_noticeLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.equalTo(payView.mas_bottom).mas_offset(40);
        make.left.equalTo(self.view).mas_offset(20);
        make.right.equalTo(self.view).mas_offset(-20);
    }];
    
    [btnWarp mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.equalTo(_noticeLb.mas_bottom).mas_offset(50);
        make.width.mas_greaterThanOrEqualTo(270);
        make.height.mas_greaterThanOrEqualTo(39);
    }];
    
    [orderBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(btnWarp);
        make.top.equalTo(btnWarp);
        make.bottom.equalTo(btnWarp);
        make.width.mas_offset(120);
        make.height.mas_offset(39);
        make.right.equalTo(shopBtn.mas_left).mas_offset(-30);
    }];
    
    [shopBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(btnWarp);
        make.top.equalTo(btnWarp);
        make.bottom.equalTo(btnWarp);
        make.width.mas_offset(120);
        make.height.mas_offset(39);
    }];
}

- (void)toOrderListClick {
    HEOrderViewController *vc = [HEOrderViewController new];
    vc.index = 0;
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)toShopClick {
    // 回到首页
    kAppDelegate.mainTabBar.selectedIndex =  0;
    [self.navigationController popToRootViewControllerAnimated:YES];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
